﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;

namespace FCMS.Mvc.Controllers.Site
{
    public class CommonController : SiteBaseController
    {
        public ActionResult GetVerifyCode()
        {
            return new VerifyCodeResult();
        }

        [HttpPost]
        public ActionResult UploadFile()
        {
            if (Request.Files.Count > 0)
            {
                foreach (string file in Request.Files)
                {
                    HttpPostedFileBase upload = Request.Files[file] as HttpPostedFileBase;
                    var now = DateTime.Now;
                    var fileNmae = string.Format(@"{0}_{1}_{2}_{3}_{4}",
                        now.ToString("yyyy"),
                        now.ToString("MM"),
                        now.ToString("dd"),
                        (1000000000000 + (now - now.Date).Ticks),
                        upload.FileName);
                    string filePath = Path.Combine(HttpContext.Server.MapPath("~/uploadfile"),
                                                  Path.GetFileName(fileNmae));
                    upload.SaveAs(filePath);
                    return Content("/Uploads/" + fileNmae);
                }
            }
            return Content("0");
        }
    }
}
